
class Booking
  
  def initialize(booking_code, date, departure, duration, flightnr, category, gender, first_name, surname, price)
    @booking_code = booking_code
    @connection = Connection.new(flightnr, departure, duration, date)
    @category = category
    @gender = gender
    @first_name = first_name.strip
    @surname = surname.strip
    @price = price.to_i
  end
  
  def booking_code
    return @booking_code
  end
  
  def connection
    return @connection
  end
  
  def date
    return @connection.departure_date
  end
  
  def departure
    return @connection.departure
  end
  
  def duration
    return @connection.duration
  end
  
  def flightnr
    return @connection.flightnr
  end
  
  def category
    return @category
  end
  
  def gender
    return @gender
  end
  
  def first_name
    return @first_name
  end
  
  def surname
    return @surname
  end
  
  def price
    return @price
  end      
  
  def to_s
    return "Booking " + date + ", departure: " + departure.to_s + ", duration: " + duration.to_s + 
      ", flightnr:" + flightnr + ", category:" + @category + ", gender: " + @gender +
      ", first name: " + @first_name + ", surname: " + @surname + ", price: " + @price.to_s
      
  end
  
end

class GroupBooking
  
  def initialize(bookings)
    raise ArgumentError, "There should be at least one booking" if bookings.size < 1
    @individual_bookings = bookings
    @connection = Connection.new(bookings[0].flightnr, bookings[0].departure, bookings[0].duration, bookings[0].date)
    @category = bookings[0].category
    @group_name = bookings[0].first_name
    @group_size = bookings.size
    @sum = 0
    bookings.each do |booking|    
      @sum = @sum + booking.price
    end
  end
  
  def connection
    return @connection
  end
  
  def date
    return @connection.departure_date
  end
  
  def departure
    return @connection.departure
  end
  
  def duration
    return @connection.duration
  end
  
  def flightnr
    return @connection.flightnr
  end
  
  def category
    return @category
  end
  
  def group_name
    return @group_name
  end
  
  def group_size
    return @group_size
  end
  
  def sum
    return @sum
  end

  def to_s
    return "Groupbooking " + date + ", departure: " + departure.to_s + ", duration: " + duration.to_s + 
      ", flightnr:" + flightnr + ", category:" + @category + ", group name: " + @group_name +
      ", group size: " + @group_size.to_s + ", sum: " + @sum.to_s
  end
  
end